/* 
** Copyright (C) 2006  sejishikong <sejishikong@263.net>
** Authors:    sejishikong <sejishikong@263.net>
**             Wei Lian <lianwei3@gmail.com> 
** Maintainer: Wei Lian
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License Version 2 as
**    published by the Free Software Foundation;
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
*/

#include "header.h"
#include "mainwindow.h"
#include "sys.h"
#include "config.h"
#include "loadsave.h"
#include "channel.h"
#include "menubar.h"
#include "tabwidget.h"

MainWindow::MainWindow(QWidget * parent, const char *name):QVBox(parent,
								 name)
{
    //menubar
    menubar = new MenuBar(this);


    ///channel row
    QHBox *hbox = new QHBox(this);
    buttonchannel = new QToolButton(hbox);
    buttonchannel->setAutoRaise(true);
    buttonchannel->setUsesTextLabel(true);
    buttonchannel->setToggleButton(TRUE);
    buttonchannel->setTextLabel(tr("Channel"));

    editsearch = new QLineEdit("", hbox);
    editsearch->setFocus();

    buttonsearch = new QToolButton(hbox);
    buttonsearch->setTextLabel(tr("Search"));
    buttonsearch->setAutoRaise(true);
    buttonsearch->setUsesTextLabel(true);

    buttonexpand = new QToolButton(hbox);
    buttonexpand->setTextLabel(tr("Expand"));
    buttonexpand->setAutoRaise(true);
    buttonexpand->setUsesTextLabel(true);

    ///sound
    sys = new Sys(this);
    slidersound =
	new QSlider(0, 100, 10, sys->sound_read(), QSlider::Horizontal,
		    hbox);

    /////vboxconfig
    vboxconfig = new Config(this);


    ///row
    channel = new Channel(this);

    ///row
/*    hbox = new QHBox(this);
    ///clock
    labelclock = new QLabel("22:22:22", hbox);
    labelclock->setFixedSize(labelclock->sizeHint());
    labelclock->setText(QTime::currentTime().toString());
*/

    ///row
    tabwidget = new TabWidget(this);

/////signal and slot  
    connect(slidersound, SIGNAL(valueChanged(int)), sys,
	    SLOT(sound_write(int)));
    connect(buttonchannel, SIGNAL(clicked()), channel,
	    SLOT(fetchchannel()));
    connect(buttonexpand, SIGNAL(clicked()), this,
	    SLOT(onbuttonexpandclicked()));
    connect(buttonsearch, SIGNAL(clicked()), this,
	    SLOT(onbuttonsearchclicked()));
    connect(editsearch, SIGNAL(returnPressed()), this,
	    SLOT(onbuttonsearchclicked()));


    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
    timer->start(1000, FALSE);

////initialization
    loadsave = new LoadSave(this);
}

MainWindow::~MainWindow()
{
    delete loadsave;
}
